import request from '@/utils/request'

/**
 * 获取预定列表
 * @param params
 * @returns {*}
 */
export function getOrderList(params) {
  return request({
    url: '/systemj/siteOrder/list',
    method: 'get',
    params: params
  })
}

/**
 * 获取预定信息
 * @param params
 * @returns {*}
 */
export function getReserveList(params) {
  return request({
    url: '/systemj/reserve/getDateOrderInfo',
    method: 'get',
    params: params
  })
}

/**
 * 获取场次价格
 * @param data
 * @param cardCode
 * @returns {*}
 */
export function getGenerdatePrice(data, cardCode, payType) {
	_.each(data,(d)=>{
		delete d.price
	})

  return request({
    url: `/systemj/reserve/generdatePrice/${cardCode || '0'}/${payType || 0}`,
    method: 'post',
    data: data
  })
}

/**
 * 预定场次
 * @param data
 * @returns {*}
 */
export function saveReserveInfo(data) {
	_.each(data.orderList,(d)=>{
		delete d.price
	})
	data.orderInfoList = JSON.stringify(data.orderList)

  return request({
    url: '/systemj/reserve/backReserveVenueWithInfoList',
    method: 'post',
    data: data
  })
}

/**
 * 锁场
 * @param data
 * @returns {*}
 */
export function saveBlockSite(data) {
  return request({
    url: '/systemj/reserve/blockSite',
    method: 'post',
    data: data
  })
}
// 修改锁场
export function blockSiteEdit(data) {
  return request({
    url: '/systemj/reserve/blockSiteEdit',
    method: 'post',
    data: data
  })
}

/**
 * 退订
 * @param id
 * @param data
 * @returns {*}
 */
export function unSubscribeOrder(id, data) {
  return request({
    url: `/systemj/reserve/unSubscribeOrderBack/${id}`,
    method: 'post',
    data: data
  })
}

/**
 * 付款
 * @param id
 * @param data
 * @returns {*}
 */
export function payForOrder(id, data) {
  return request({
    url: `/systemj/reserve/payForOrder/${id}`,
    method: 'post',
    data: data
  })
}



/**
 * 获取退费金额
 * @param id
 * @returns {*}
 */
export function getCancelOrderPrice(id) {
  return request({
    url: `/systemj/reserve/getCancelOrderPrice/${id}`,
    method: 'get'
  })
}


/**
 * 长租计算日期
 * @param params
 * @returns {*}
 */
export function generateCanOrderDate(data) {
  return request({
    url: '/systemj/reserve/generateCanOrderDate',
    method: 'post',
    data: data
  })
}

/**
 * 长租
 * @param data
 * @returns {*}
 */
export function backLongRentSite(data) {
  return request({
    url: '/systemj/reserve/backLongRentSite',
    method: 'post',
    data: data
  })
}
// 计算长租退订的价格
export function generateLongRentRefund(data) {
  return request({
    url: '/systemj/reserve/generateLongRentRefund',
    method: 'post',
    data: data
  })
}

// 长租退订
export function cancelLongRent(data) {
  return request({
    url: '/systemj/reserve/cancelLongRent',
    method: 'post',
    data: data
  })
}


export function getFatherLongRentOrder(orderId) {
  return request({
    url: `/systemj/siteOrder/getFatherLongRentOrder/${orderId}`,
    method: 'get'
  })
}
// 释放
export function releaseSiteOrder(orderId) {
  return request({
    url: `/systemj/siteOrder/releaseSiteOrder/${orderId}`,
    method: 'post'
  })
}
//预留/锁场找主订单
export function backGetInfo(id) {
  return request({
    url: `/systemj/siteOrder/backGetInfo/${id}`,
    method: 'get'
  })
}

export function getWithSon(id) {
  return request({
    url: `/systemj/siteOrder/getWithSon/${id}`,
    method: 'get'
  })
}


export function backYuLiuPay(data) {
	_.each(data.orderList,(d)=>{
		delete d.price
	})
	data.orderInfoList = JSON.stringify(data.orderList)

  return request({
    url: '/systemj/reserve/backYuLiuPay',
    method: 'post',
    data: data
  })
}
